import os
from cryptography.fernet import Fernet

BANNER = '''
██████╗  ██████╗██████╗ ██╗   ██╗██████╗ ████████╗
██╔══██╗██╔════╝██╔══██╗╚██╗ ██╔╝██╔══██╗╚══██╔══╝
██║  ██║██║     ██████╔╝ ╚████╔╝ ██████╔╝   ██║   
██║  ██║██║     ██╔══██╗  ╚██╔╝  ██╔═══╝    ██║   
██████╔╝╚██████╗██║  ██║   ██║   ██║        ██║   
╚═════╝  ╚═════╝╚═╝  ╚═╝   ╚═╝   ╚═╝        ╚═╝   
'''

def process_directory(path: str, cipher: Fernet, mode: str) -> None:
    for root, _, files in os.walk(path):
        for file in files:
            file_path = os.path.join(root, file)
            process_file(file_path, cipher, mode)

def process_file(file_path: str, cipher: Fernet, mode: str) -> None:
    with open(file_path, 'rb') as f:
        data = f.read()
    if mode == 'encrypt':
        new_data = cipher.encrypt(data)
        new_path = file_path + '.enc'
    elif mode == 'decrypt':
        new_data = cipher.decrypt(data)
        new_path = file_path[:-4] if file_path.endswith('.enc') else file_path
    with open(new_path, 'wb') as f:
        f.write(new_data)
    if new_path != file_path:
        os.remove(file_path)
